package com.ybf.user.dal.manager;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ybf.user.dal.entity.RoleMenuDO;
import com.ybf.user.dal.mapper.RoleMenuMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.Collections;
import java.util.List;
import java.util.Objects;

@Component
public class RoleMenuManager extends ServiceImpl<RoleMenuMapper, RoleMenuDO> {


    @Autowired
    private RoleMenuMapper roleMenuMapper;

    /**
     * 列表
     *
     * @author 向南
     * @date 14:32 2023/7/31
     * @param: roleId
     **/
    public List<RoleMenuDO> selectByRoleId(Long roleId) {
        if (Objects.isNull(roleId)) {
            return Collections.emptyList();
        }
        return roleMenuMapper.selectList(new LambdaQueryWrapper<RoleMenuDO>().eq(RoleMenuDO::getRoleId, roleId));
    }

    /**
     * 查询列表
     *
     * @author 向南
     * @date 16:49 2023/7/31
     * @param: roleIds
     **/
    public List<RoleMenuDO> selectInRoleIds(List<Long> roleIds) {
        if (CollectionUtils.isEmpty(roleIds)) {
            return Collections.emptyList();
        }
        return roleMenuMapper.selectList(new LambdaQueryWrapper<RoleMenuDO>().in(RoleMenuDO::getRoleId, roleIds));
    }
}
